<?php
/**
 * @version 0.8.3 2010-10-07
 * @package Joomla
 * @subpackage LeagueResults
 * @copyright (C)  2008, 2009, 2010 Henryk Drozd
 * @license GNU/GPL, see LICENSE.php
 * LeagueResults is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2
 * as published by the Free Software Foundation.

 * LeagueResults is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.controller');

class lrControllerSettings extends lrController {

	function __construct()
	{
		
		parent::__construct();
		
			$this->registerTask( 'add', 'edit' );
			$this->registerTask( 'apply', 'save' );
			
	}

	function cancel()
	{
		// Check for request forgeries
		JRequest::checkToken() or die( 'Invalid Token' );
		


		$this->setRedirect( 'index.php?option=com_lr' );
	}


	function edit( )
	{
	
		JRequest::setVar( 'view', 'settings' );
		JRequest::setVar( 'hidemainmenu', 1 );

		$model 	= $this->getModel('settings');
		$user	=& JFactory::getUser();

		
		parent::display();
	}
	function save()
	{
		// Check for request forgeries
		JRequest::checkToken() or die( 'Invalid Token' );

		$task		= JRequest::getVar('task');

		$post = JRequest::get( 'post' );
		
		

		$model = $this->getModel('settings');
//print_r($post);sssss();
		if ($returnid = $model->store($post)) {

			switch ($task)
			{
				case 'apply' :
					$link = 'index.php?option=com_lr&controller=settings&view=settings&hidemainmenu=1&cid[]='.$returnid;
					break;

				default :
					$link = 'index.php?option=com_lr';
					break;
			}
			$msg	= JText::_( 'SETTINGS SAVED');

			$cache = &JFactory::getCache('com_lr');
			$cache->clean();

		} else {

			$msg 	= '';
			$link = 'index.php?option=com_lr&view=settings';

		}



		$this->setRedirect( $link, $msg );
 	}
 	
function edit_css( )
	{
	
		JRequest::setVar( 'view', 'editcss' );
		JRequest::setVar( 'hidemainmenu', 1 );
		parent::display();
	}

	
}
?>
